import { makeAutoObservable } from 'mobx';
import { inject, injectable } from 'inversify';
import { DashboardModel } from '../models/dashboard.model.ts';
import { DashboardRepository } from '../data/dashboard.repository.ts';

@injectable()
export class DashboardViewModel {
  get loading() {
    return this.dashboardModel.loading;
  }

  constructor(
    @inject(DashboardModel)
    private dashboardModel: DashboardModel,
    @inject(DashboardRepository)
    private dashboardRepository: DashboardRepository,
  ) {
    makeAutoObservable(this);
  }

  async getJoke() {
    this.dashboardModel.loading = true;
    await this.dashboardRepository.getInfo();

    this.dashboardModel.loading = false;
  }

  dispose() {
    this.dashboardModel.dispose();
  }
}
